package com.library.mapper;

import com.library.entity.BrowseHistory;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BrowseHistoryMapper {


    @Insert("insert into browse_history" +
            "(user_id,book_id,book_title,browse_date,category_id) " +
            "values" +
            "(#{userId},#{bookId},#{bookTitle},#{browseDate},#{categoryId})")
    void insert(BrowseHistory browseHistory);

    /**
     * 根据用户id获取浏览记录书籍id
     * @param userId
     * @return
     */
    @Select("select book_id from browse_history where user_id = #{userId}")
    List<Long> getBookIdsByUserId(Long userId);

    /**
     * 根据用户id获取浏览记录书籍分类id
     * @param userId
     * @return
     */
    @Select("select category_id from browse_history where user_id = #{userId}")
    List<Long> getCategoryIdsByUserId(Long userId);

    /**
     * 根据分类id获取浏览记录书籍id
     * @param categoryIds
     * @return
     */
    List<Long> getRecommendationsBookIdsByCategoryIds(List<Long> categoryIds);
}
